# Maintainer: Hoang Nguyen <folliekazetani@protonmail.com>
pkgname=pwru
pkgver=1.0.7
pkgrel=0
pkgdesc="eBPF-based Linux kernel networking debugger"
url="https://github.com/cilium/pwru"
arch="x86_64 aarch64" # the only platforms supported upstream
license="GPL-2.0-or-later"
makedepends="go clang llvm libpcap-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/cilium/pwru/archive/refs/tags/v$pkgver.tar.gz"

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	export CGO_CFLAGS="$CFLAGS"
	export CGO_LDFLAGS="$LDFLAGS -L/usr/lib -lpcap"

	TARGET_GOARCH=$(go env GOARCH) go generate
	go build -v -ldflags "-X github.com/cilium/pwru/internal/pwru.Version=v$pkgver"
}

check() {
	go test ./...
}

package() {
	install -Dm755 $pkgname -t "$pkgdir"/usr/bin/
}

sha512sums="
3192426824d8261a4f637622c43361f2b6855e42b6791432ca254794ff8b19e002aa8da3cbc08e8f1b19562f480c0bde0aa2d4aca8f19f952bd54bc96a695256  pwru-1.0.7.tar.gz
"
